package com.example.springmcpserver.service;

import org.springframework.ai.tool.annotation.Tool;
import org.springframework.ai.tool.annotation.ToolParam;
import org.springframework.stereotype.Component;

import java.util.HashMap;
import java.util.Map;
import org.springframework.stereotype.Service;

@Service
public class WeatherToolsService {

  @Tool(name = "getWeatherByCity", description = "根据城市名获取天气信息")
  public Map<String, Object> getWeatherByCity(@ToolParam(description = "城市名称") String city) {
    System.out.println("-------------------getWeatherByCity------------------" + city);
    Map<String, Object> result = new HashMap<>();
    result.put("city", city);
    result.put("temperature", "30°C");
    result.put("condition", "晴");
    result.put("humidity", "40%");
    return result;
  }

  @Tool(name = "getWeatherByCoordinates", description = "根据经纬度获取天气信息")
  public Map<String, Object> getWeatherByCoordinates(@ToolParam(description = "纬度") double latitude,
                                                     @ToolParam(description = "经度") double longitude) {
    System.out.println("-------------------getWeatherByCoordinates------------------" + latitude + "," + longitude);

    Map<String, Object> result = new HashMap<>();
    result.put("latitude", latitude);
    result.put("longitude", longitude);
    result.put("temperature", "28°C");
    result.put("condition", "多云");
    result.put("windSpeed", "15 km/h");
    return result;
  }
}
